/*
Phone List
Given a list of phone numbers, determine if it is consistent in the sense that no number is the prefix of another. Let's say the phone catalogue listed these numbers:

Emergency 911
Alice 97 625 999
Bob 91 12 54 26
In this case, it's not possible to call Bob, because the central would direct your call to the emergency line as soon as you had dialled the first three digits of Bob's phone number. So this list would not be consistent.
Input
The first line of input gives a single integer, 1 ≤ t ≤ 40, the number of test cases. Each test case starts with n, the number of phone numbers, on a separate line, 1 ≤ n ≤ 10000. Then follows n lines with one unique phone number on each line. A phone number is a sequence of at most ten digits.
Output
For each test case, output "YES" if the list is consistent, or "NO" otherwise.
Sample Input
2
3
911
97625999
91125426
5
113
12340
123440
12345
98346
Sample Output
NO
YES
给出一些字符串，判断是否有字符串是另一个字符串的前缀
有的话输出NO，没有的话输出YES
*/
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cstring>
#define ll long long
#define PI acos(-1)
#define M(n, m) memset(n, m, sizeof(n));
const int INF = 1e9 + 7;
const int maxn = 10000 + 100;
using namespace std;
//maxnode和sigma_size的大小要随题意更改
const int maxnode = 100000, sigma_size = 10;
int ch[maxnode][sigma_size];
int val[maxnode];
int sz;

struct Trie
{
    Trie()
    {
        sz = 1;
        memset(ch[0], 0, sizeof(ch[0]));
    }

    int idx(char c)
    {
        return c - '0';
    }
    
    bool Insert(char *s)
    {
        int u = 0, len = strlen(s);
        bool flag = false;
        for (int i = 0; i < len; i ++)
        {
            int c = idx(s[i]);
            if (!ch[u][c])
            {
                //这是一个新的节点，说明到现在为止，这个串新开辟了位置，肯定不是之前某个串的前缀
                flag = true;

                memset(ch[sz], 0, sizeof(ch[sz]));
                val[sz] = 0;
                ch[u][c] = sz ++;
            }
            u = ch[u][c];
            //遇到了之前某个串的结尾。肯定不符合题意
            if (val[u])
                return true;
        }
        val[u] = 1;
        //还没有开辟新位置，显然新插入的字符串是之前某个串的前缀
        if (!flag)
            return true;
        return false;
    }
};

char s[maxn];
int T, n;

int main()
{
    scanf("%d", &T);
    while(T --)
    {
        bool flag = false;
        Trie t;
        scanf("%d", &n);
        for (int i = 0; i < n; i ++)
        {
            scanf("%s", s);
            if (!flag)
                flag = t.Insert(s);
        }
        if (!flag)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}
